package cn.wh.test;

import java.lang.reflect.Proxy;

/**
 * @Description TODO
 * @Version 1.0.0
 * @Date 2022/11/18 17:25
 * @Created wh
 */
public class App {
    public static void main(String[] args) {
        IVehical car=new Car();
        IVehical o = (IVehical) Proxy.newProxyInstance(car.getClass().getClassLoader(), car.getClass().getInterfaces(), new VehicalInvacationHandler(car));
        o.run();
//     IVehical iVehical=(IVehical) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[]{IVehical.class},(proxy, method, args1) ->{
//            System.out.println(12);
//            System.out.println("谁知道你嘛这是啥");
//            return proxy;
//        } );
//     iVehical.run();

        IVehical iVehical1=(IVehical) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[]{IVehical.class},(proxy, method, a) ->{
            if (a==null){
                return proxy;
            }
            for (Object ad : a) {
                System.out.println(ad);
            }
            return proxy.getClass().getClassLoader().getName();
        } );
        iVehical1.run();
        System.out.println(iVehical1.run("123"));


    }

}
